package easy;

import java.util.Arrays;

/**
 * @author admin
 * 1502. 判断能否形成等差数列
 * 等差数列判定，中间数的两倍等于前后两数之和
 */
public class LeeCode1502 {

    public boolean canMakeArithmeticProgression(int[] arr) {
        Arrays.sort(arr);
        for (int i = 1; i < arr.length - 1; i++) {
            if (arr[i]*2 != arr[i-1] + arr[i+1]){
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        System.out.println(new LeeCode1502().canMakeArithmeticProgression(new int[]{20,17,-18,-13,13,-14,-8,10,1,14,-19}));
    }
}
